//模块配置信息
require.config({
	//baseUrl: "./",
	paths: {
		//工具模块
		'less': 'tools/less.min',
		'jquery': 'tools/jquery.min',
		'bootstrap': 'tools/bootstrap.min',
		'handlebars': 'tools/handlebars',

		//配置模块
		'config': './config',
		"appConfig":"./appConfig",

		'top_bar': 'modules/top_bar',
		'article': 'modules/article',
		'showBigImg': 'modules/showBigImg',
		'studioInfo': 'modules/studioInfo',
		'ask': 'modules/ask',
		'modal_template': 'modules/modal_template',
		'cookie': 'modules/cookie',
		'check_log': 'modules/check_log',
		'login': 'modules/login',
		'other_log': 'modules/login',
		'reg': 'modules/reg',
		'user': 'modules/user',
	},
	skim: {  //配置依赖关系与接口
		"bootstrap": {	// bootstrap依赖jquery库
			deps: ['jquery'],
			exports: 'bootstrap'
		},
		"handlebars": {
			exports: 'Handlebars'
		},
		"user": {
			deps: ['modal_template']
		}
	}
});


//加载LESS, jquery, bootstrap
require(['less', 'jquery'], function(){
	require(['bootstrap']);	
});

//加载顶栏top_bar模块
require(['top_bar'], function(top_bar){
	top_bar();
});

//取出url参数
var url = window.location.href;
var reg = /articleId=[\s|\S]+$/;
if (reg.test(url)){
	var articleId = reg.exec(url)[0];
	articleId = articleId.split('=')[1];
}
reg = /studioId=[\s|\S]+(?=&)/;
if (reg.test(url)){
	var studioId = reg.exec(url)[0];
	studioId = studioId.split('=')[1];
}

//加载中心问题模块，并用Hanlebars生成
require(['article', 'cookie'], function(article, cookie){
	if (articleId){
		article.getArticleById(articleId);
	}
});

//加载右方画室信息模块
require(['studioInfo'], function(studioInfo){
	if (studioId){
		studioInfo.getStudioById(studioId);
		studioInfo.clickWatch();
	}
});

//加载提问模块
require(['jquery'], function($){
	var load_times = 0;
	$(document).on('click', '.ask-button', function(){
		if (load_times == 0){
			load_times ++;
			//加载提问模块(向画室提问)
			require(['ask'], function(ask){
				ask(studioId);
			});
		}
	});
});